package cn.csc.module.product.api.tagref;

import cn.csc.framework.common.pojo.CommonResult;
import cn.csc.module.product.api.tagref.dto.SpuTagReferenceDTO;
import cn.csc.module.product.convert.tagref.SpuTagReferenceConvert;
import cn.csc.module.product.dal.dataobject.tagref.SpuTagReferenceDO;
import cn.csc.module.product.service.tagref.SpuTagReferenceService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigInteger;
import java.util.List;

import static cn.csc.module.product.enums.ApiConstants.VERSION;

/**
 * @author liuchuang
 * @version 1.0
 * @modify
 * @since 2025/1/15 17:53
 */
@RestController // 提供 RESTful API 接口，给 Feign 调用
@DubboService(version = VERSION) // 提供 Dubbo RPC 接口，给 Dubbo Consumer 调用
@Validated
public class SpuTagReferenceApiImpl implements SpuTagReferenceApi {

    @Resource
    private SpuTagReferenceService spuTagReferenceService;

    /**
     * 查询spu对应的tag信息
     *
     * @param spuId 参数
     * @return
     */
    @Override
    public CommonResult<List<SpuTagReferenceDTO>> getBySpuId(BigInteger spuId) {
        List<SpuTagReferenceDO> bySpuId = spuTagReferenceService.getBySpuId(spuId);
        return CommonResult.success(SpuTagReferenceConvert.INSTANCE.convertList03(bySpuId));
    }


}
